# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=qt5-charts
_basever=5.15.18
pkgver=5.15.18
pkgrel=3
_commit=1093fb53ced126100d14af30a8adffd29b7ef855
arch=('x86_64' 'aarch64')
url='https://www.qt.io'
license=('GPL-3.0-only')
pkgdesc='Provides a set of easy to use chart components.'
depends=('qt5-base')
makedepends=('qt5-declarative' 'git')
optdepends=('qt5-declarative: QML bindings')
_pkgfqn=${pkgname/5-/}
source=("kde-$_pkgfqn::git+https://invent.kde.org/qt/qt/$_pkgfqn#commit=$_commit")
sha512sums=('e0be16cf3e09cc9c3fafdfb5e43b2f9eeab95b12e55ea8b38993c71430eb3c2e88275f6f1bb75e8a859bc99f36c700c9f8475ca7405dcbb758d9d6811f3f8c45')

pkgver() {
  cd "kde-$_pkgfqn"

  echo "$_basever+kde+r"`git rev-list --count v$_basever-lts-lgpl..$_commit` |
    sed -e 's|+kde+r0||'
}

prepare() {
  mkdir -p build
}

build() {
  cd build

  qmake "../kde-$_pkgfqn"

  make
}

package() {
  cd build

  make INSTALL_ROOT="$pkgdir" install

  # Drop QMAKE_PRL_BUILD_DIR because reference the build dir
  find "$pkgdir/usr/lib" -type f -name '*.prl' \
    -exec sed -i -e '/^QMAKE_PRL_BUILD_DIR/d' {} \;
}

